<template>
	<view class="my">
		<view class="user_base">
			<view class="left">
				<image :src="userInfo.avatar || '../../static/icon/banner.png'"></image>
				<text>{{userInfo.nickName || '微信用户忙'}}</text>
			</view>
			<view class="right" @click="toEditInfo">
				<text>去完善信息</text>
				<image src="../../static/icon/right.png"></image>
			</view>
		</view>

		<view class="links">
			<u-cell-group>
				<u-cell title="我的房屋" isLink url="/pkg-house/house/house">
					<image class="left-icon" slot="icon" src="../../static/icon/myhouse.png"></image>
				</u-cell>
				<u-cell title="我的报修" isLink url="/pkg-house/repair-room/repair-room">
					<image class="left-icon" slot="icon" src="../../static/icon/myrepair.png"></image>
				</u-cell>
				<u-cell :border="false" title="访客记录" isLink>
					<image class="left-icon" slot="icon" src="../../static/icon/myfriends.png"></image>
				</u-cell>
			</u-cell-group>
		</view>

		<u-button type="primary" text="退出登录" @click="logout"></u-button>

		<u-modal showCancelButton :show="show" title="享+生活" content='确认退出该账号？' @cancel="onCancel" @confirm="onConfirm">
		</u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.user.userInfo
			}
		},
		methods: {
			logout() {
				this.show = true
			},
			onCancel() {
				this.show = false
			},
			onConfirm() {
				this.$store.commit('user/setUserToken', null)
				uni.removeStorageSync('userToken')
				this.show = false
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			toEditInfo() {
				uni.navigateTo({
					url: '/pages/userInfo/userInfo'
				})
			}
		},
		onLoad() {
			this.$store.dispatch('user/loadUserInfo')
		}
	}
</script>

<style lang="scss" scoped>
	.my {
		height: 100%;
		background-color: #FAFAFA;

		.user_base {
			width: 750rpx;
			height: 482rpx;
			padding: 128rpx 40rpx 0 40rpx;
			border-radius: 0px 0px 60px 60px;
			background: #6394C0;
			display: flex;
			justify-content: space-between;
			box-sizing: border-box;

			.left {
				height: 80rpx;
				display: flex;
				align-items: center;

				image {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
				}

				text {
					color: #fff;
					font-size: 40rpx;
					margin-left: 20rpx;
				}
			}

			.right {
				height: 80rpx;
				display: flex;
				align-items: center;

				text {
					color: #fff;
					font-size: 28rpx;
					margin-right: 10rpx;
				}

				image {
					width: 32rpx;
					height: 32rpx;
					color: #fff;
				}
			}
		}

		.links {
			width: 670rpx;
			height: 306rpx;
			background-color: #fff;
			border-radius: 16rpx;
			margin: 0 auto;
			margin-top: -136rpx;

			::v-deep .u-cell__body {
				padding: 0 25rpx;
				height: 102rpx;

				.u-cell__title-text {
					color: #3C3E42 !important;
					font-size: 28rpx !important;
				}
			}

			.left-icon {
				width: 40rpx;
				height: 40rpx;
				margin-right: 25rpx;
			}
		}

		::v-deep .u-button {
			width: 670rpx;
			border: none;
			background-color: #6394C0;
			margin: 25rpx auto;
		}
	}
</style>
